<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:77:"E:\web\project\baojia\wwwww\public/../application/admin\view\jishu\kedit.html";i:1535378364;s:70:"E:\web\project\baojia\wwwww\application\admin\view\layout\default.html";i:1529292885;s:67:"E:\web\project\baojia\wwwww\application\admin\view\common\meta.html";i:1535990037;s:69:"E:\web\project\baojia\wwwww\application\admin\view\common\script.html";i:1533222223;}*/ ?>
<!DOCTYPE html>
<html lang="<?php echo $config['language']; ?>">
    <head>
        <meta charset="utf-8">
<title><?php echo (isset($title) && ($title !== '')?$title:''); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="renderer" content="webkit">

<link rel="shortcut icon" href="/public/assets/img/favicon.ico" />
<!-- Loading Bootstrap -->
<link href="/public/assets/css/backend<?php echo \think\Config::get('app_debug')?'':'.min'; ?>.css?v=<?php echo \think\Config::get('site.version'); ?>" rel="stylesheet">
<link href="/public/assets/js/uploadify/uploadify.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>
  <script src="/public/assets/js/html5shiv.js"></script>
  <script src="/public/assets/js/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
    var require = {
        config:  <?php echo json_encode($config); ?>
    };
</script>
<script src="/public/assets/libs/jquery/dist/jquery.min.js"></script>
<script src="/public/assets/js/uploadify/jquery.uploadify.min.js"></script>
    </head>

    <body class="inside-header inside-aside <?php echo defined('IS_DIALOG') && IS_DIALOG ? 'is-dialog' : ''; ?>">
        <div id="main" role="main">
            <div class="tab-content tab-addtabs">
                <div id="content">
                    <div class="row">
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                            <section class="content-header hide">
                                <h1>
                                    <?php echo __('Dashboard'); ?>
                                    <small><?php echo __('Control panel'); ?></small>
                                </h1>
                            </section>
                            <?php if(!IS_DIALOG && !$config['fastadmin']['multiplenav']): ?>
                            <!-- RIBBON -->
                            <div id="ribbon">
                                <ol class="breadcrumb pull-left">
                                    <li><a href="dashboard" class="addtabsit"><i class="fa fa-dashboard"></i> <?php echo __('Dashboard'); ?></a></li>
                                </ol>
                                <ol class="breadcrumb pull-right">
                                    <?php foreach($breadcrumb as $vo): ?>
                                    <li><a href="javascript:;" data-url="<?php echo $vo['url']; ?>"><?php echo $vo['title']; ?></a></li>
                                    <?php endforeach; ?>
                                </ol>
                            </div>
                            <!-- END RIBBON -->
                            <?php endif; ?>
                            <div class="content">
                                <script src="../../../../public/assets/js/require-backend.js"></script>
<form id="add-form" class="form-horizontal" method="POST" action="<?php echo url('ksave'); ?>">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">名称:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" name="name" value="<?php echo (isset($data['name']) && ($data['name'] !== '')?$data['name']:''); ?>" class="form-control"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">开发模式:</label>
        <div class="col-xs-12 col-sm-8" id="cate_select">
            <label style="font-weight: normal;margin-right: 15px;cursor: pointer;"><input style="position: relative;top: 2px;" name="develop_model" value="1" 
                <?php if((!empty($data)) AND $data['develop_model'] == 1): ?>checked<?php endif; ?> type="radio">系统服务</label>
            <label style="font-weight: normal;margin-right: 15px;cursor: pointer;"><input style="position: relative;top: 2px;" name="develop_model" value="2"
                 <?php if((empty($data)) OR $data['develop_model'] == 2): ?>checked<?php endif; ?> type="radio">单一服务</label>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">所属部分:</label>
        <div class="col-xs-12 col-sm-8">
            <label style="font-weight: normal;margin-right: 15px;cursor: pointer;">
                <input style="position: relative;top: 2px;" name="type" value="1"
                       <?php if((!empty($data)) AND $data['type'] == 1): ?>checked<?php endif; ?> type="radio">独立部分</label>
            <label style="font-weight: normal;margin-right: 15px;cursor: pointer;">
                <input style="position: relative;top: 2px;" name="type" value="2"
                       <?php if((!empty($data)) AND $data['type'] == 2): ?>checked<?php endif; ?> type="radio">通用部分</label>
        </div>
    </div>

    <div class="form-group price">
        <label class="control-label col-xs-12 col-sm-2">应用版本:</label>
        <div class="col-xs-12 col-sm-8">
           <div class="fixed-table-body">
                <table id="table" class="table table-striped table-bordered table-hover" width="100%" style="background-color: #fff;">
                    <thead>
                        <tr>
                            <th style="text-align: center; vertical-align: middle; ">
                                <div class="th-inner ">应用版本</div>
                                <div class="fht-cell"></div>
                            </th>
                            <th style="text-align: center; vertical-align: middle; ">
                                <div class="th-inner ">价格</div>
                                <div class="fht-cell"></div>
                            </th>
                        </tr>
                    </thead>
                    <tbody data-listidx="0" id="app_version">
                       <?php if(is_array($versions) || $versions instanceof \think\Collection || $versions instanceof \think\Paginator): $i = 0; $__LIST__ = $versions;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?> 
                         <tr data-index="<?php echo $key; ?>">
                            <td style="text-align: center; vertical-align: middle;">
                                <label><input  value="<?php echo $vo['id']; ?>" <?php if(!empty($list[$vo['id']])): ?>checked<?php endif; ?>  type="checkbox"><?php echo $vo['name']; ?></label>
                            </td>
                            <td style="text-align: center; vertical-align: middle;">
                                <input type="text" value="<?php echo (isset($list[$vo['id']]) && ($list[$vo['id']] !== '')?$list[$vo['id']]:''); ?>"  class="form-control" id="price_<?php echo $vo['id']; ?>"/>
                            </td>
                         </tr>
                        <?php endforeach; endif; else: echo "" ;endif; ?> 
                      
                    </tbody>
                </table>
            </div>
        </div>
     </div>

     <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <label><input value="0" type="radio" <?php if(!empty($list[0])): ?>checked <?php endif; ?> id="price_radio">无版本</label>
            <input type="text" class="form-control" value="<?php echo (isset($list[0]) && ($list[0] !== '')?$list[0]:''); ?>" id="price_0"/>
        </div>
       
    </div>
   
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">应用范畴:</label>
        <div class="col-xs-12 col-sm-8 cate cate_1" id="cate_1" <?php if((empty($data)) OR $data['develop_model'] != 1): ?>style="display: none;" <?php endif; ?>>
           <?php if(is_array($list1) || $list1 instanceof \think\Collection || $list1 instanceof \think\Paginator): $i = 0; $__LIST__ = $list1;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>  
            <label style="font-weight: normal;margin-right: 15px;cursor: pointer;"><input style="position: relative;top: 2px;" name="cate_id" type="radio" <?php if((!empty($data)) AND $data['cate_id'] == $vo['id']): ?>checked<?php endif; ?> value="<?php echo $vo['id']; ?>"><?php echo $vo['name']; ?></label>
           <?php endforeach; endif; else: echo "" ;endif; ?>  
        </div>
         <div class="col-xs-12 col-sm-8 cate cate_2" id="cate_2" <?php if((!empty($data)) AND $data['develop_model'] != 2): ?>style="display: none;" <?php endif; ?>>
           <?php if(is_array($list2) || $list2 instanceof \think\Collection || $list2 instanceof \think\Paginator): $i = 0; $__LIST__ = $list2;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>  
            <label style="font-weight: normal;margin-right: 15px;cursor: pointer;"><input style="position: relative;top: 2px;" name="cate_id" type="radio" <?php if((!empty($data)) AND $data['cate_id'] == $vo['id']): ?>checked<?php endif; ?> value="<?php echo $vo['id']; ?>"><?php echo $vo['name']; ?></label>
           <?php endforeach; endif; else: echo "" ;endif; ?>  
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">单位:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" name="company" value="<?php echo (isset($data['company']) && ($data['company'] !== '')?$data['company']:''); ?>" class="form-control"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">描述:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea type="text" name="des" id="des" class="form-control"><?php echo (isset($data['des']) && ($data['des'] !== '')?$data['des']:''); ?></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <input type="hidden" name="id" value="<?php echo (isset($data['id']) && ($data['id'] !== '')?$data['id']:''); ?>" class="form-control"/>
            <button type="submit" id="submit" class="btn btn-success btn-embossed"><?php echo __('OK'); ?></button>
        </div>
    </div>
</form>

<script>
    $(function(){
        $("#cate_select").find(":radio").click(function(){
            var cate_id=$(this).val();
            $(".cate").hide();
            $(".cate_"+cate_id).css("display","block");
        })
        $("#submit").click(function(){
             var items = new Array();
            if($("#price_radio").is(":checked")){
                var version=0;
                var price=$("#price_0").val();
                items.push([version,price]);
            }else{
                 var cheklist=$("#app_version").find(":checked");
                 for (var i = 0; i < cheklist.length; i++) {
                    var version=$(cheklist[i]).val();
                    var price=$("#price_"+version).val();
                    var item=[version,price];
                    items.push(item);
                 }
            }
            var version_price=JSON.stringify( items );
         
           
           var name=$("input[name=name]").val();
           var develop_model=$("input[name=develop_model]:checked").val();
           var cate_id=$("input[name=cate_id]:checked").val();
           var company=$("input[name=company]").val();
           var des=$("#des").val();
           var type=$("input[name=type]:checked").val();
           var id=$("input[name=id]").val();
           if(name==''){
               alert("请填写名称");
               return false;
           }
           if(develop_model==2 && type==undefined){
               alert("请选择所属部分");
               return false;
           }
           $.ajax({
                    type:'POST',
                    data:{
                        version_price:version_price,
                        name:name,
                        develop_model:develop_model,
                        cate_id:cate_id,
                        company:company,
                        des:des,
                        type:type,
                        id:id
                    },
                    url:"<?php echo url('ksave'); ?>",
                    success:function(data){                            
                          if(data.code==1){
                            alert(data.msg);
                            window.location.href=data.url;
                          }else{
                            alert(data.msg);
                          }
                    }
            });   
            return false;        
        });

    })
</script>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
<script src="/public/assets/js/require<?php echo \think\Config::get('app_debug')?'':'.min'; ?>.js" data-main="/public/assets/js/require-backend<?php echo \think\Config::get('app_debug')?'':'.min'; ?>.js?v=<?php echo $site['version']; ?>"></script>
    </body>
</html>